package com.jackrain.nea.common;

import org.springframework.http.client.SimpleClientHttpRequestFactory;
import org.springframework.stereotype.Component;
import org.springframework.web.client.RestTemplate;

/**
 * Created by zhoucheng on 17/10/27.
 */
@Component
public class RestTemplateIn {

    private RestTemplate restTemplate;

    public RestTemplate getRestTemplate() {

        if (restTemplate == null) {
            SimpleClientHttpRequestFactory factory = new SimpleClientHttpRequestFactory();
            factory.setReadTimeout(600000);//ms
            factory.setConnectTimeout(15000);//ms
            restTemplate = new RestTemplate(factory);
        }

        return restTemplate;

    }

}